#coding:utf8

import sys,os
if os.name!='nt':#对系统的类型的判断，如果不是NT系统的话使用epoll
    from twisted.internet import epollreactor
    epollreactor.install()

from twisted.internet import reactor
from twisted.python import log
from firefly.netconnect.protoc import LiberateFactory
from firefly.utils.services import CommandService
import Role_pb2

reactor = reactor
factory = LiberateFactory()
commandService = CommandService('testService')



def serviceHandle(target):
    '''服务处理
    @param target: func Object
    '''
    commandService.mapTarget(target)

@serviceHandle
def handle_1(conn, reuqest):
    argement = Role_pb2.CreatePlayerRequest()
    argement.ParseFromString(reuqest)
    print(argement.name, argement.password)

def serverstart():
    print("serverstart")
    log.startLogging(sys.stdout)
    factory.addServiceChannel(commandService)
    reactor.listenTCP(34530,factory)
    reactor.run()

if __name__ == "__main__":
    serverstart()

